package parser;
%%
%class Scanner
%function nextToken
%type Token

%unicode
%line
%column

%{ 
  /**
   * Utility methode om een token te maken.
   * @param kind token soort
   * @see TokenKinds
   */
  private Token createToken(TokenKind tokenKind) {
	return new Token(tokenKind, yytext(), yyline + 1, yycolumn + 1);
  }
%}

NEWLINE = \.
WHITESPACE = [\ \t\b\012]
NONTERMINAL = \< [a-zA-Z0-9\-]+ \>
TERMINAL = [^\<\>\|::=\ \.]+
QUOTESTERMINAL = \" [^\"]* \"
ISDEFINEDAS = ::=
OR = \|
EMPTY = \ε

%%

<YYINITIAL> {
	{WHITESPACE}		{ }
	{EMPTY}				{ return createToken(TokenKind.EMPTY); }
  	{NONTERMINAL}		{ return createToken(TokenKind.NONTERMINAL); }
  	{ISDEFINEDAS}		{ return createToken(TokenKind.ISDEFINEDAS); }
  	{OR}				{ return createToken(TokenKind.OR); }
	{NEWLINE}			{ return createToken(TokenKind.EOL); }
	{TERMINAL}			{ return createToken(TokenKind.TERMINAL); }
	{QUOTESTERMINAL}	{ return createToken(TokenKind.TERMINAL); }
	<<EOF>>         	{ return createToken(TokenKind.EOF); }
}